// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import axios from "axios"
import Router from "vue-router"
import routes from "./route"
Vue.prototype.axios=axios  //全局axios对象设置
axios.defaults.headers.post['Content-Type'] = 'application/json';
Vue.config.productionTip = false
Vue.use(Router)//使用路由
const router = new Router({
  routes:routes,
  mode:"history"
})
Vue.directive("rainbow",{
  bind(el,binding,vnode){
    //el 当前指令坐在的元素标签对象  binding 获取当前指令的参数 和值
    el.style.color = "#"+Math.random().toString(16).slice(2,8);
  }
})
Vue.directive("theme",{
  bind(el,binding,vnode){
    //el 当前指令坐在的元素标签对象  binding 获取当前指令的参数 和值
    if(binding.value == 'wide') {
      el.style.width = "1600px" ;
    }else if (binding.value == "narrow") {
      el.style.width = "600px" ;
    }else {
      el.style.width = "800px" ;
    }
    if(binding.arg == 'column') {
      el.style.background = "pink"
      el.style.padding = "20px"
    }
  }
})
//自定义过滤器
Vue.filter("to-upperCase",function (value) {
  return value.toUpperCase();
})
Vue.filter("showContentByTen",function (value) {
  return value.slice(0,10)
})
/* eslint-disable no-new */
new Vue({
  router,
  el: '#app',
  components: { App },
  template: '<App/>'
})
